package com.wangkang.oss.controller;
import com.wangkang.commonutils.R;
import com.wangkang.oss.service.IOssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@Api(tags = "阿里云OSS文件上传")
@RestController
@RequestMapping("/eduoss/fileoss")
//@CrossOrigin
public class OssController {

    @Autowired
    private  IOssService ossService;

    public OssController(IOssService ossService) {
        this.ossService = ossService;
    }

    @ApiOperation("上传文件")
    @PostMapping
    public R uploadOssFile(@ApiParam("文件") MultipartFile file){

        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url",url);
    }
}